package com.workless.config;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class SshWebListener implements ServletContextListener {

    private SshConnection conexionssh;

    public SshWebListener() {
        super();
    }
    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        System.out.println("SSHWebListener initialized ... !");
        try {
            conexionssh = new SshConnection();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    @Override
    public void contextDestroyed(ServletContextEvent arg0) {
        System.out.println("SSHWebListener destroyed ... !");
        conexionssh.closeSSH();
    }
}

//import org.springframework.stereotype.Component;
//
//import javax.servlet.ServletContextEvent;
//import javax.servlet.ServletContextListener;
//import javax.servlet.annotation.WebListener;
//
//@WebListener
//@Component
////public class SshContextListener implements ServletContextListener {
//public class SshWebListener implements ServletContextListener {
//    private SshConnection sshConnection;
//
//    @Override
//    public void contextInitialized(ServletContextEvent arg0) {
//        System.out.println("==========>Context initialized...");
//        try {
//            sshConnection = new SshConnection();
//            sshConnection.init();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//    @Override
//    public void contextDestroyed(ServletContextEvent arg0) {
//        System.out.println("==========>Context destroyed...");
//        try {
//            sshConnection.destroy();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//}

